package org.fenixsoft.jvm.chapter13.my;

public class NotifyTest {

    public static void main(String[] args) throws Exception {
        final NotifyTest test = new NotifyTest();
        for(int i=0;i<5;i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    synchronized (test){
                        System.out.println(Thread.currentThread().getName() +" Start-----");

                        try {
                            test.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }

                        System.out.println(Thread.currentThread().getName() +" End-------");
                    }
                }
            }).start();
        }

        synchronized (test) {
            test.notify();
        }
        Thread.sleep(3000);
        System.out.println("-----------分割线-------------");

        synchronized (test) {
            test.notifyAll();
        }
    }
}
